<template>
	<view class="content">
		<!-- 通知栏、轮播图 -->
		<view class="notice-box">
			<uni-notice-bar show-icon scrollable
				:text="noticeBar.length == 0? '创建订单前，请务必预览word文件': noticeBar[0].text" />		
		</view>
		
		<!-- 上传进度条 -->
		<view class="progress-box ">
			<view class="progress-item cu-btn animation-reverse margin-sm basis-sm shadow" :class="[item.progress >= 101 ? 'animation-slide-right': '']" v-for="item in uploadingList" v-show="true">
				<view style="color:#0278FF;">{{item.name }}</view>
				<view class="cu-progress round sm striped" :class="item.active?'active':''">
					<view class="bg-green" :style="'width:' + item.progress +'%;'">{{item.progress < 100 ? Math.ceil(item.progress)+'%' : '文件合并中'}}</view>
				</view>
			</view>
		</view>
		<!-- 文件列表 -->
		<view class="upload-file-box">
			<view class="uploaded-file" v-for="item,index in uploadedFiles" :key="index">				
				<view class="file-index">
					{{index+1}}
				</view>
				<view class="file-type-image">
					<image v-if="item.suffix == 'pdf'" style="width: 100%" mode="widthFix" src="../../../static/images/type-pdf.png"></image>
					<image v-else-if="item.suffix == 'doc' || item.suffix == 'docx'" style="width: 100%;" mode="widthFix" src="../../../static/images/type-word.png"></image>
					<image v-else-if="item.suffix == 'png' || item.suffix == 'jpg' || item.suffix == 'webp'" mode="widthFix" src="../../../static/images/type-image.png"></image>										
					<image v-else src="../../../static/images/unknownfile.png" mode="widthFix"></image>
				</view>
				<view class="file-detail-box">
					<view class="file-name">{{item.storeName}}</view>
					<view class="print-setting" v-if="item.fileParameter">
						{{getprintParam(item.fileParameter.size,templateSize).label}}/
						{{getprintParam(item.fileParameter.face,templateFace).label}}/
						{{getprintParam(item.fileParameter.color,templateColor).label}}/
						{{item.fileParameter.pages}}份/
						{{item.fileParameter.begin==0 || item.fileParameter.end==0 ? '全部' : item.fileParameter.begin +'-'+item.fileParameter.end}}页
						<!-- {{item.fileParameter.bookingType}}-{{item.fileParameter.bookingWay}} -->
					</view>
					<view class="file-price">
						<text style="font-size: large;">￥{{item.fileParameter.price}}</text>					
					</view>
					<view class="file-set-bar">
						<button class="cu-btn line-orange sm">
							<uni-icons type="eye" size="20"></uni-icons>
							 预览
						</button>
						<button @click="openSetFile('bottom',item)" class="set-button cu-btn line-orange sm">
							<uni-icons type="gear" size="18"></uni-icons>
							设置
						</button>
					</view>
				</view>
				<uni-icons @click="deleteFile()" type="closeempty" class="delete-button" color="#999999" size="25"></uni-icons>
			</view>
		</view>
		 
		<!-- 添加文件图标、添加文件的弹窗 -->
		<view class="add-icon" @click="openAddfile">
			<uni-icons type="plusempty" color="#fff"></uni-icons>
		</view>
		<view class="add-file-back" v-show="showAddfile" @click="acloseAddfile"></view>
		<view class="add-ways" v-show="showAddfile">			
				<view class="add-way-item" @click="chooseWxfile">
					<image mode="aspectFit" src="/static/images/chat-file.png"></image>
					<text>聊天文件</text>
				</view>
				<view class="add-way-item">
					<image mode="aspectFit" src="/static/images/photo-file.png"></image>
					<text>图片文件</text>
				</view>				
		</view>
		<view class="example-body">
			
		</view> 
		
		<!-- 文件参数设置 -->
		<!-- 普通弹窗 -->
		<uni-popup ref="popup" class="setfile-popup" background-color="#8f8f93"  :mask-click="false" >
			<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
				<view class="popup-title">
					<image v-if="chooseFileParam.suffix == 'pdf'" style="width: 50rpx" mode="widthFix" src="../../../static/images/type-pdf.png"></image>
					<image v-else-if="chooseFileParam.suffix == 'doc' || chooseFileParam.suffix == 'docx'" style="width: 50rpx" mode="widthFix" src="../../../static/images/type-word.png"></image>
					<image v-else-if="chooseFileParam.suffix == 'png' ||chooseFileParam.suffix == 'jpeg' || chooseFileParam.suffix == 'jpg' || chooseFileParam.suffix == 'webp'" style="width: 50rpx" mode="widthFix" src="../../../static/images/type-image.png"></image>										
					<image v-else src="../../../static/images/unknownfile.png" style="width: 50rpx" mode="widthFix"></image>										
					
					<!-- <image v-if="chooseFileParam.suffix" style="width: 50rpx" mode="widthFix" src="../../../static/images/type-pdf.png"></image> -->
					<!-- <image v-if="index==1" style="width: 100%;" mode="widthFix" src="../../../static/images/type-word.png"></image> -->
					<!-- <image v-if="index==2" style="width: 100%;" mode="widthFix" src="../../../static/images/type-image.png"></image>															 -->
					<text class="popu-title-text">{{chooseFileParam.storeName}}</text>					
				</view>
				<view class="list-line"></view>
				<view class="list-item">
					<view class="set-item-name">纸形</view>
					<view class="set-item-button">
						<view v-for="item in templateSize" >					
							<button @click="setfiletype('size',item.value)" v-if="item.status" :class="[chooseFileParameter.size==item.value?'bg-blue':'line-blue']" class="set-button cu-btn sm">{{item.label}}</button>
						</view>
					</view>
				</view>
				<view class="list-line"></view>
				<view class="list-item">
					<view class="set-item-name">颜色</view>
					<view class="set-item-button">
						<view v-for="item in templateColor" >
							<button @click="setfiletype('color',item.value)" v-if="item.status" :class="[chooseFileParameter.color==item.value?'bg-blue':'line-blue']" class="set-button cu-btn sm">{{item.label}}</button>
						</view>
					</view>
				</view>
				<view class="list-line"></view>
				<view class="list-item">
					<view class="set-item-name">单双</view>
					<view class="set-item-button">
						<view v-for="item in templateFace" >
							<button @click="setfiletype('face',item.value)" v-if="item.status" :class="[chooseFileParameter.face==item.value?'bg-blue':'line-blue']" class="set-button cu-btn sm">{{item.label}}</button>
						</view>
					</view>
				</view>
				<view class="list-line"></view>
				<view class="list-item">
					<view class="set-item-name">份数</view>
					<view class="set-item-button"> 
						<uni-number-box v-model="chooseFileParameter.pages" :min="1" :step="1" @change="changeValue" /> 
					</view>
				</view>
				<view class="list-line"></view>
				<view class="list-item">
					<view class="set-item-name">打印范围</view>
					<view class="set-item-button" @click="openSetRange"> 
						第
						<input class="page-set" :value="chooseFileParameter.begin==0? '1':chooseFileParameter.begin" disabled />
						-
						<input class="page-set" :value="chooseFileParameter.end==0? chooseFileParam.filePages : chooseFileParameter.end" disabled />
						页
					</view>
				</view>
				<view class="list-line"></view>
				<view class="list-item">
					<view class="set-item-name">装订方式</view>
					<view class="set-item-button">
						<view v-for="item in bookingWay" >
							<button @click="setfiletype('bookingWay',item.value,item.type)" v-if="item.status" :class="[chooseFileParameter.bookingWay == item.value?'bg-blue':'line-blue']" class="set-button cu-btn sm">{{item.label}}</button>
						</view> 
					</view>
				</view>
				<view class="list-line"></view>
				<view class="list-item">
					<view class="set-item-name">装订设置</view>
					<view class="set-item-button">
						<view v-for="item in bookingType" >
							<button @click="setfiletype('bookingType',item.bPId)" :class="[chooseFileParameter.bookingType==item.bPId?'bg-blue':'line-blue']" class="set-button cu-btn sm">{{item.bookingWay}}</button>
						</view> 
					</view>
				</view>
				<view class="list-line"></view>
				<view class="button-item">					
					<button class="cu-btn round line-orange lg" @click="closeSetFile">取消</button>					
					<button class="cu-btn round bg-blue lg" @click="confireSetFile">确认</button>					
				</view>
			</view>
		</uni-popup>
		
		<!-- 打印范围设置 -->
		<view class="cu-modal bottom-modal" :class="modalName=='bottomModal'?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white">
					<view class="action text-blue" @click="hideModal">取消</view>
					<view class="action text-green" @click="confiresetPage">确定</view>
				</view>
				<view class="padding-xl" v-if="modalName=='bottomModal'?'show':''">
					<picker-view  :value="prePageValue"  @change="bindChange" class="picker-view">
            <picker-view-column>
							<view v-for="(item,index) in printPageList">								
                <view  class="item" :key="index">{{item}}页</view>
							</view>
            </picker-view-column>
            <picker-view-column>
							<view v-for="(item,index) in printPageList">								
                <view  class="item" :key="index">{{item}}页</view>
							</view>
            </picker-view-column> 
        </picker-view>
				</view>
			</view>
		</view>
		
		<!-- 底部操作条 -->
		<view class="cu-bar bg-white tabbar border shop addorder-bar">
			
			<view class="btn-group addorder-button-box">
				
				<view class="bar-left">共{{uploadedFiles.length}}个文件</view>				
				<view class="baar-price">合计￥{{allFilePrice}}</view>
				<button class="cu-btn bg-red round addorder-button shadow-blur" @click="createOrder()">创建订单</button>
			</view>
		</view>
	</view>
</template>

<script>
	import { getNoticeByDeptId } from '@/api/notice/index.js'
	import { uploadFile } from '@/utils/uploadfile.js'
	import { mergeChunk } from '@/api/print/upload.js'
	import { getPrintFileList, setPrintFileParam } from '@/api/file/index.js'
	import { getPricePararm, getBookingPrice } from '@/api/price/index.js'
	import { login } from '../../../api/login'
	export default {
		data() {
			return {
				showAddfile: false,
				uploadingList: [
					// {active: true, name: '文件1', progress:60},
					// {active: true, name: '文件1', progress:50.3},
					// {active: true, name: '文件1', progress:40},
				],	
				uploadedFiles: [1,2,3],
				color: 'red',
				loading: false,
				modalName: '',
				active: false,
				type: '',
				array: ['中国', '美国', '巴西', '日本'],
				index: 0,
				// 通知栏
				noticeBar: [],
				//学校信息
				deptData: this.$store.state.system.location,
				uploadedChunkList: null,
				 /*打印参数模板*/
				templateSize:[
					{value: 0,label: 'A3',status: 0},
					{value: 1,label: 'A4',status: 0},
					{value: 2,label: 'A5',status: 0},
				],
				templateFace:[
					{value: 0,label: '单面',status: 0},
					{value: 1,label: '双面',status: 0},
				],
				templateColor:[
					{value: 0,label: '黑色',status: 0},
					{value: 1,label: '彩色',status: 0},
				],
				templateType:[
					{value: 0,label: '文件',status: 0},
					{value: 1,label: '图片',status: 0},
				],
				// 被选中的打印文件
				tempFile: null,
				chooseFileParam: {
					deleteFlag: null,
					fileId: null,
					filePages: null,
					fileParameter: {},
					innerId: null,
					moduleId: null,
					originalName: null,
					outerId: null,
					remarks: null,
					size: null,
					storeName: null,
					suffix: null,
					uploadDate: null,
					uploaderId: null,
				},
				//被选中的打印文件信息
				chooseFileParameter: {
					begin: null,
					bookingType: null,
					bookingWay: null,
					color: null,
					end: null,
					fPId: null,
					face: null,
					fileId: null,
					pages: null,
					size: null,
					status: null,
				},
				// 打印价格
				printPrice: [],
				// 装订价格
				bookingPrice: [],
				//装订方式
				bookingWay:[
					{value: -1,label: '不装钉',status: 1,type:[
						{bPId: -1,bookingWay:'默认'},
					]},
					{value: 0,label: '订书订',status: 0,type:[
						// {bPId: 4,bookingWay:'默认1'},
					]},
					{value: 1,label: '回形针',status: 0,type:[
						// {bPId: 2,bookingWay:'默认2'}, 
					]},
					{value: 2,label: '长尾夹',status: 0,type:[
						// {bPId: 5,bookingWay:'默认3'}, 
					]},
					{value: 3,label: '塑封',status: 0,type:[
						// {bPId: 6,bookingWay:'默认4'}, 
					]},
				],
				bookingType: [],
				// 打印文件页面选择
				printPageList: [1,2,3,4,5,6,7,8,9],
				printPagebegin: 0,
				printPageend: 0,
				// 同步打印文件页面选择
				prePageValue: [1,2],
				allFilePrice: 0,//文件总价
			}
		},
		async created() {
			//加载所有的分包上传文件、为断点续传做服务
			// this.uploadedChunkList = uni.getStorageSync('uploadedChunk');
			// console.log(this.uploadedChunkList);
			// let flag = 1000;
			// while(flag--){
			// 	this.uploadedChunkList.push('hasfsadfasdfasdfasdfsh1')
			// }
			// this.uploadedChunkList = ['hasfsadfasdfasdfasdfsh1','hassadfasdfsdafasdfh2','sdafasdfsadfasdfasdfhash3']
			// setInterval(()=>{if(this.uploadingList[0].progress<100)this.uploadingList[0].progress++},100)
			this.getPrintNotice();//获取所有通知
			await this.getFileList();//查询所有文件
			this.clearFile();	//清理上传进度条
			await this.getPrice();//查询文件价格
			await this.getBookingPrice();//装订价格
			this.computeAllPrice()//计算所有文件价格
		},
		onShow() {
		},
		onUnload(){
			// this.$store.commit('SET_CHUNK',this.uploadedChunkList)
			// uni.setStorageSync('uploadedChunk',this.uploadedChunkList);			
		},
		methods: {
			//获取所有文件总价
			getAllFilePrice(){
				this.allFilePrice = this.uploadedFiles.reduce((pre,cur,index)=>{
					return pre + cur.fileParameter.price
				},0)
			},			
			//计算所有文件价格
			computeAllPrice(){
				this.uploadedFiles.forEach(item=>{
					this.getFilePrice(item)
				})
				this.getAllFilePrice()
			},
			// 计算单个文件价格
			getFilePrice(FileParam){
				const suffix = FileParam.suffix
				const fileParameter = FileParam.fileParameter
				if(suffix=='pdf'||suffix=='doc'||suffix=='docx'){
					FileParam.fileParameter.type = 0
				}else if(suffix=='png'||suffix=='jpg'||suffix=='webp'||suffix=='jpeg'){					
					FileParam.fileParameter.type = 1
				}				
				const onefacefilePrice = this.printPrice.find(item=>{
					if(item.size != FileParam.fileParameter.size) return false
					if(item.face != 0) return false
					if(item.color != FileParam.fileParameter.color) return false
					if(item.type != FileParam.fileParameter.type) return false
					return true
				})		
				const twofacefilePrice = this.printPrice.find(item=>{
					if(item.size != FileParam.fileParameter.size) return false
					if(item.face != 1) return false
					if(item.color != FileParam.fileParameter.color) return false
					if(item.type != FileParam.fileParameter.type) return false
					return true
				})
				fileParameter.price = 0
				// 1设置打印价格
				if(fileParameter.begin==0) fileParameter.begin = 1
				if(fileParameter.end==0) fileParameter.end = FileParam.filePages
				if(fileParameter.face==0){
					console.log('0000');
					console.log(onefacefilePrice);
					console.log(fileParameter); 
					fileParameter.price = onefacefilePrice.price * (fileParameter.end - fileParameter.begin + 1)*fileParameter.pages
				}else if(fileParameter.face==1){
					console.log('1111');
					if(0==(fileParameter.end-fileParameter.begin + 1)%2){		
					console.log('11000');				
						fileParameter.price = twofacefilePrice.price *fileParameter.pages * (fileParameter.end-fileParameter.begin + 1)/2
					}else{
					console.log('11222');		
						fileParameter.price = twofacefilePrice.price *fileParameter.pages * parseInt((fileParameter.end-fileParameter.begin + 1)/2)+onefacefilePrice.price
					}					
				}else{
					uni.showToast({
						title: '文件类型有误'
					})
				}
				// 2设置装订价格
				const bookingPrice = this.bookingPrice.find(item=>{
					if(fileParameter.bookingType == item.bPId){return true}
				})
				if(bookingPrice != undefined){
					fileParameter.price += bookingPrice.price
				}
				// fileParameter.price = fileParameter.price.toFixed(2) * 1.0
				//重新计算总价
				this.getAllFilePrice()				
				console.log('bookingPrice',bookingPrice);
				console.log(FileParam);
				console.log('onefacefilePrice',onefacefilePrice);
				console.log('twofacefilePrice',twofacefilePrice);
				// console.log('FileParam.fileParameter',FileParam.fileParameter);
			},
			// 查询装订价格
			async getBookingPrice(){
			  await	getBookingPrice().then(res=>{
					console.log('getBookingPrice',res);
					if(res.rows.length!=0){
						// 更新可以使用的装订价格
						this.bookingPrice = res.rows
						res.rows.forEach(bookingPrice=>{
							this.bookingWay.forEach(bookingWay=>{
								if(bookingPrice.bookingWay==bookingWay.value){
									bookingWay.status = 1
									let type = {}
									type.bPId = bookingPrice.bPId
									type.bookingWay = bookingPrice.bookingType
									bookingWay.type.push(type)
								}
							})
						})
					}
				})
			},
			// 重设可配置的打印方式
			setCanUsePrintParam(){ 
				// console.log(this.templateSize); 
				// console.log(this.templateFace); 
				// console.log(this.templateColor); 
				// console.log(this.templateType); 
				// console.log(this.printPrice); 
				// console.log(this.chooseFileParameter); 
				// console.log(this.chooseFileParam); 
				// 1判断文件类型
				const suffix = this.chooseFileParam.suffix
				if(suffix=='pdf'||suffix=='doc'||suffix=='docx'){
					this.chooseFileParameter.type = 0
				}else if(suffix=='png'||suffix=='jpg'||suffix=='webp'||suffix=='jpeg'){					
					this.chooseFileParameter.type = 1
				}
				// 2清除可以设置的打印参数
				this.templateSize.forEach(item2=>{ 
					item2.status = 0
				})
				this.templateFace.forEach(item2=>{
					item2.status = 0
				})
				this.templateColor.forEach(item2=>{
					item2.status = 0
				})
				// 3分别设置的打印参数
				let keys = ['size','face','color']
				for(let key of keys){
					let filterList = this.printPrice.filter(item=>{ 
						if(key!='size' && item.size != this.chooseFileParameter.size) return false
						if(key!='face' && item.face != this.chooseFileParameter.face) return false
						if(key!='color' && item.color != this.chooseFileParameter.color) return false
						if(item.type != this.chooseFileParameter.type) return false						
						return true
					})
					// console.log('filterList',filterList);
					filterList.forEach(item=>{
						if(key=='size'){
							this.templateSize.forEach(item2=>{ 
								if(item2.value == item[key])item2.status = 1
							})
						}
						if(key=='face'){
							this.templateFace.forEach(item2=>{
								if(item2.value == item[key]) {item2.status = 1}
							})							
						}
						if(key=='color'){
							this.templateColor.forEach(item2=>{
								if(item2.value == item[key]) {item2.status = 1}
							})
						}
					})
						// console.log('1',this.templateSize);
						// console.log('2',this.templateFace);
						// console.log('3',this.templateColor);
				}  
				
			},
			// 确认打印页数
			confiresetPage(){
				if(this.printPagebegin>this.printPageend){
					uni.showToast({
						icon: 'error',
						title: '打印范围有误',
						duration: 1000,
					});
					return
				}
				this.chooseFileParameter.begin = this.printPagebegin
				this.chooseFileParameter.end = this.printPageend
				this.getFilePrice(this.chooseFileParam)
				console.log(this.chooseFileParameter);
				this.modalName = ''
			},
			// 选择打印页数
			bindChange(value){
				// console.log(this.printPageList);
				// console.log(value.detail.value[0]);
				// console.log(value.detail.value[1]);
				if(value.detail.value[0]>=0){
					this.printPagebegin = this.printPageList[value.detail.value[0]]
				}
				if(value.detail.value[1]>=0){
					this.printPageend = this.printPageList[value.detail.value[1]]
				}
			},
			//获取打印价格 
			async getPrice(){
			  await	getPricePararm().then(res=>{
					// console.log('res',res);
					this.printPrice = res.rows
				})
			},
			/*获取打印参数*/
			getprintParam(value,template,){
				return template.find(currentValue=>{
					if(currentValue.value == value) return true
				})
			},
			//获取页面所有文件信息
			async getFileList(){
				const res = await getPrintFileList();
				console.log('res',res);
				this.uploadedFiles = res.rows
			},
			openAddfile(){
				this.showAddfile = true
			},
			acloseAddfile(){
				this.showAddfile = false
			},
			//选择微信聊天图片
			chooseWxfile(){
				// #ifdef MP-WEIXIN
				console.log("@@");
				wx.chooseMessageFile({
					count: 10,
					type: 'image',
					success (res) {
						// tempFilePath可以作为 img 标签的 src 属性显示图片
						const tempFilePaths = res.tempFiles
						console.log('tempFilePaths',tempFilePaths)
						uploadFile(res.tempFilePaths);
					}
				})
				// #endif 
				// #ifndef MP-WEIXIN
				let that = this
				uni.chooseFile({
				  count: 5, //默认100
				  extension:['.doc','.docx','png','txt','jpg','mp4','exe'],
					success: function (res) {
						that.showAddfile = false
						console.log('res',res);
						console.log(JSON.stringify(res.tempFilePaths));
						console.log(res.tempFiles);
						res.tempFiles.forEach(item=>{
							item.progress = 0.0 
							that.uploadingList.push(item) 
							setInterval(()=>{
								that.$forceUpdate()
							},100)
						})
						console.log('res.tempFiles:',res.tempFiles);
						uploadFile(res.tempFiles);
						// uploadFile(res.tempFilePaths,2);
					}
				});
				// #endif

			},
			//店家删除文件
			deleteFile(){
				console.log("deleteFile");
			},
			//打开、关闭文件设置
			openSetFile(type,fileParam){
				this.type = type
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open(type)	
				this.tempFile = JSON.stringify(fileParam)
				this.chooseFileParam = fileParam
				this.chooseFileParameter = fileParam.fileParameter
				//设置默认装订方式
				this.bookingWay.forEach(item=>{
					if(item.value == fileParam.fileParameter.bookingWay) this.bookingType = item.type
				})
				// 设置可以打印的文件页数
				this.printPageList = []
				let index = 1
				while(index<=this.chooseFileParam.filePages){
					this.printPageList.push(index++)
				}
				// 设置可以打印设置的参数
				this.setCanUsePrintParam()
				console.log(fileParam);
			},
			//取消文件设置
			closeSetFile(){
				let temp = JSON.parse(this.tempFile)
				for (let key in temp) { 
				 this.chooseFileParam[key] = temp[key] // foo, bar 
				}
				// console.log('temp',temp);
				this.$refs.popup.close()
			},
			//确认文件设置
			async confireSetFile(){
				const res = await setPrintFileParam(this.chooseFileParameter).then(res=>{
					// uni.showToast("修改成功")
					uni.showToast({
						title: '修改成功',
						duration: 1000
					});
					this.$refs.popup.close()
				})
				// let temp = JSON.parse(this.tempFile)
				// for (let key in temp) {
				//  this.chooseFileParam[key] = temp[key] // foo, bar 
				// }
				// console.log('temp',temp);
			},
			//设置打印参数 
			setfiletype(key,type,bookingType){
				if('bookingWay'==key){
					this.bookingType = bookingType
					this.chooseFileParameter.bookingType = bookingType[0].bPId
				}
				this.chooseFileParameter[key] = type
				this.setCanUsePrintParam(key,type)
				this.getFilePrice(this.chooseFileParam)
			},
			//改变份数
			changeValue(value){
				console.log('value',value);
				this.setfiletype('pages',value)
				// this.chooseFileParameter.pages = value
			},
			//打印范围改变
			bindPickerChange: function(e) {
					console.log('picker发送选择改变，携带值为', e.detail.value)
					this.index = e.detail.value
			},
			//打开文件页数设置			
			openSetRange(){
				this.modalName = 'bottomModal'
				this.printPagebegin = this.chooseFileParameter.begin
				this.printPageend = this.chooseFileParameter.end
				if(this.chooseFileParameter.begin == 0){
					this.prePageValue[0] = 0
				}else{
					this.prePageValue[0] = this.chooseFileParameter.begin - 1
				}
				if(this.chooseFileParameter.end == 0){
					this.prePageValue[1] = this.chooseFileParam.filePages- 1
				}else{
					this.prePageValue[1] = this.chooseFileParameter.end - 1
				}
				console.log(this.prePageValue);
			},
			//关闭文件页数设置
			hideModal(){
				this.modalName = ''
			},
			//创建订单
			createOrder(){
				let item = {
					list: this.uploadedFiles
				}
				item.allPrice = this.uploadedFiles.reduce(function(prev, cur, index, arr) {
						console.log(prev, cur, index);
						return prev + cur.fileParameter.price;
				},0)
				console.log('item.allPrice',item.allPrice);
				this.$store.commit('SET_UPLOADEDFILE',item)
				uni.navigateTo({
					url: '/pages/print/checkout/index'
				})
			},			
			//获取通知栏、轮播图
			async getPrintNotice(){
				const res = await getNoticeByDeptId(this.deptData.deptId,1);
				if(res.code !=200) return uni.showToast({
					title: '加载通知失败'
				})
				if(res.rows.length != 0) res.rows.forEach(item=>{
					if(item.innerId == 3) this.noticeBar.push(item)
				})
				
			},
			//清理上传成功文件
			clearFile(){
				let that = this
				//监控
				let falg = setInterval(()=>{
					that.uploadingList.forEach((item,index)=>{
						if(item.progress >= 101){
							setTimeout(()=>{
								that.uploadingList.forEach((item,index)=>{
									if(item.progress >= 101){
										that.uploadingList.splice(index,1)											
									}
								})
							},1500)
							return
						}
					})
				},100)				
			}
		}
	}
</script>

<style >
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		overflow: hidden;
	}
	
	/* 通知栏 */
	.notice-box {
		/* background-color: #0278FF; */
		width: 92vw;
		height: 80rpx;
		margin-top: 30rpx;
		border-radius: 20rpx;
		overflow: hidden;
	}
	
	/* 进度条 */
	.progress-box{
		width: 92vw;
	}
	.progress-item{
		width: 100%;
		margin: 2rpx 0;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
	}
	
	/* 添加文件图标、添加文件的弹窗 */
	.add-icon{
		position: fixed;
		bottom: 150rpx;
		right: 50rpx;
		background-color: #0278FF;
		width: 100rpx;
		height: 100rpx;		
		border-radius: 50%;
		box-shadow: #cde5ff 2rpx 5rpx 5rpx;
		
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.add-file-back{
		position: fixed;
		z-index: 10;
		margin:0;
		top: 0;
		width: 100vw;
		height: 100vh;
		background-color: #000000;
		opacity: 0.5;
	}
	.add-ways{
		z-index: 100;
		background-color: white;
		color: #000000;
		opacity: 1;
		position: fixed;
		top: 40vh;
		left: 20vw;
		width:60vw;
		height: 200rpx;
		border-radius: 20rpx;
		
		display: flex;
		justify-content: space-around;
		align-items: center;
	}
	.add-way-item{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		height: 100%;
	}
	
	.add-way-item>image{
		height: 100rpx;
		width: 100rpx;
	}
	
	/* 文件列表 */
	.upload-file-box{		
		width: 92vw;
		margin-bottom: 300rpx;
	}
	.uploaded-file{
		position: relative;
		width: 100%;
		min-height: 200rpx;
		border-radius: 20rpx;
		overflow: hidden;
		background-color: white;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		margin-top: 30rpx;
	}
	.file-index{
		padding: 30rpx;
		width: 10%;
		font-size: large;
	}
	.file-type-image{
		width: 15%;
		margin-right: 4%;
	}
	.file-detail-box{
		/* background-color: #0278FF; */
		height: 100%;
		width: 71%;
		
		/* display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start; */
	}
	.delete-button{		
		position: absolute;
		margin: 5rpx;
		top: 0;
		right: 0;
		/* background-color: #cde5ff; */
	}
	/* 文件详情 */
	.file-name{
		/* background-color: #cde5ff; */
		width: 85%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		margin-top: 30rpx;
		font-size: large;
	}
	.print-setting{
		color: #999999;
	}
	.file-price{
		margin-left: -8rpx;
		color: #FF0000;
	}		
	.file-set-bar{
		padding-right: 10rpx;
		padding-bottom: 10rpx;
		
		display: flex;
		justify-content: flex-end;
	}
	.set-button{
		margin: 0 10rpx;
	}
	
	/* 弹出层 */
	.popup-content { 
			align-items: center;
			justify-content: center;
			padding: 5px;
			min-height: 50px;
			background-color: #fff;
			border-top-left-radius: 30rpx;
			border-top-right-radius: 30rpx;
			overflow: hidden;
			/* border-radius: 30rpx; */
	}
	.setfile-popup{
		border-radius: 30rpx;
		border-top-right-radius: 30rpx;
		overflow: hidden;		
	}
	.popup-title{
		margin: 15rpx;
		margin-left: 15rpx;
		font-size: large;
		display: flex;
		justify-content: flex-start;
		align-items: center; 
	}
	.popu-title-text{
		margin-left: 5rpx;
	} 
	.list-item{
		min-height: 90rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.list-line{
		width: 100%;
		height: 1rpx;
		background-color: #d1d1d1;
	}
	.set-item-name{
		margin-left: 15rpx;
		font-size: large;
	}
	.set-item-button{
		display: flex;
		justify-content: flex-end;
		align-items: center;
		flex-wrap: wrap;
		
		flex-direction: row;
	}
	.set-item-button button{
		margin: 5rpx;
	}
	.page-set{
		width: 80rpx;
		height: 50rpx;
		margin: 0 10rpx;
		text-align: center;
		border-radius: 10rpx;
		overflow: hidden;
		/* background-color: #e2e2e2; */
		border: #c1c1c1 solid 1rpx;
	}
	.set-item-button > .mini-btn{
		margin: 0 10rpx;
	}
	.button-item{
		height: 120rpx;
		align-items: center;
		display: flex;
		justify-content: space-around;
	}
	.button-item button{
		width: 35%;
	}
	
	/* 底部导航条 */
	.addorder-bar{
		position: fixed;
		bottom: 0;
		width: 100vw;
	}
	.bar-left{
		width: 30vw;
	}
	.addorder-button{
		width: 30vw;
	}
	/* 页数选择 */
	.picker-view {
		width: 750rpx;
		height: 400rpx;
		margin-top: 20rpx;
	}
	.item {
		height: 50px;
		align-items: center;
		justify-content: center;
		text-align: center;
	}
</style>
